<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <h2>模板语法</h2>
      <!-- v-once用于做一次性的渲染 -->
      <p v-once>{{ count }}</p>
      <p>{{ count }}</p>
      <div>{{ content }}</div>
      <!-- v-html将内容当作html进行渲染, 相当于innerHTML -->
      <!-- 小心xss攻击，只能对信得过的内容使用v-html -->
      <div v-html="content"></div>
      <!-- v-text指令将内容当作字符串进行渲染, 相当于innerTEXT, 跟双大括号的效果是一样的 -->
      <div v-text="content"></div>

      <p v-bind:[key]="value">hello</p>
      <!-- <img v-bind:[attr]="url" alt="" /> -->

      <img :src="url" alt="" @click="fn" />
    </div>

    <script src="../Vue.js"></script>
    <script>
      new Vue({
        el: "#app",
        data: {
          count: 1,
          content: "<h1>标题</h1>",
          value: "hello",
          key: "title",
          url: "https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png",
          attr: "data",
        },
        mounted() {
          setInterval(() => {
            this.count++;
          }, 1000);

          setTimeout(() => {
            this.attr = "src";
          }, 3000);
        },
        methods: {
          fn() {
            console.log(123);
          },
        },
      });
    </script>
  </body>
</html>
